package com.wnhoo.smartfishtank.util;


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import java.util.Locale;

public class UIUtil {
    public static boolean isZh(Context context) {
        Locale locale = context.getResources().getConfiguration().locale;
        String language = locale.getLanguage();
        if (language.endsWith("zh"))
            return true;
        else
            return false;
    }
    public static int convertDpToPixel(Context paramContext, float paramFloat) {
        return (int) (paramFloat * (paramContext.getResources().getDisplayMetrics().densityDpi / 160.0F));
    }

    public static int dp2Px(Context paramContext, float paramFloat) {
        return (int) (0.5F + paramFloat * paramContext.getResources().getDisplayMetrics().density);
    }

    public static Bitmap getBitmap(Context paramContext, int paramInt) {
        BitmapFactory.Options localOptions = new BitmapFactory.Options();
        localOptions.inSampleSize = 4;
        return BitmapFactory.decodeResource(paramContext.getResources(), paramInt, localOptions);
    }
//    public static Bitmap readBitMap(Context context, int resId){
//        BitmapFactory.Options opt = new BitmapFactory.Options();
//        opt.inPreferredConfig = Bitmap.Config.ARGB_8888;
//        opt.inPurgeable = true;
//        opt.inInputShareable = true;
//      //获取资源图片
////        InputStream is = context.getResources().openRawResource(resId);
//        return BitmapFactory.decodeResource(context.getResources(),resId,opt);
//    }

}